import numpy as np
import matplotlib.pyplot as plt
import cv2
from numpy.core.fromnumeric import size

d = 400
img = np.ones((d, d, 3), dtype="uint8") * 255
#生成白色背景
for i in range(0, 100):
    centerX = np.random.randint(0, high=d)
    # 生成随机圆心cneterX, 确保在画布img内
    centerY = np.random.randint(0, high=d)
    # 将图像的中心作为圆心，实际值为d/2
    radius = np.random.randint(5, high=d / 15)
    # 生成随机半径，值范围为[5, d/5], 最大半径是d/5
    color = np.random.randint(0, high=256, size=(3, )).tolist()
    #生成随机颜色，3个[0, 256]的随机数
    cv2.circle(img, (centerX, centerY), radius, color, -1)
    # 使用上述随机数在画布img内画圆
plt.figure('Demo16.6')
plt.imshow(img)
plt.axis('off')
plt.title("Demo16.6")
plt.show()
